Skip to content

Conversation

@calren
Copy link
Collaborator

@calren calren commented May 22, 2025

This commit applies the initial changes to migrate from the firebase-vertexai SDK to the new firebase-ai (Firebase AI Logic SDK).

Key changes include:

  1. Updated ai-catalog/gradle/libs.versions.toml:
    • Bumped firebaseBom to 33.14.0.
    • Switched firebase-vertexai to firebase-ai.
  2. Updated ai-catalog/app/build.gradle.kts:
    • Changed dependency to libs.firebase.ai.
  3. Updated AI SDK usage in the Imagen sample:
    • Modified ai-catalog/samples/imagen/src/main/java/com/android/ai/samples/imagen/ImagenViewModel.kt to use the new firebase-ai SDK, including import changes and updating the ImagenModel initialization to use Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(...).

The core/network/build.gradle.kts and a central FirebaseAiDataSource.kt as seen in the reference PR for androidify were not found in this repository's structure. The Imagen-specific AI logic was updated directly in its ViewModel.

Further steps, including updating the README.md, remain.

This commit applies the initial changes to migrate from the
firebase-vertexai SDK to the new firebase-ai (Firebase AI Logic SDK).

Key changes include:

1.  Updated `ai-catalog/gradle/libs.versions.toml`:
    *   Bumped `firebaseBom` to `33.14.0`.
    *   Switched `firebase-vertexai` to `firebase-ai`.
2.  Updated `ai-catalog/app/build.gradle.kts`:
    *   Changed dependency to `libs.firebase.ai`.
3.  Updated AI SDK usage in the Imagen sample:
    *   Modified `ai-catalog/samples/imagen/src/main/java/com/android/ai/samples/imagen/ImagenViewModel.kt` to use the new `firebase-ai` SDK, including import changes and updating the ImagenModel initialization to use `Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(...)`.

The `core/network/build.gradle.kts` and a central `FirebaseAiDataSource.kt` as seen in the reference PR for `androidify` were not found in this repository's structure. The Imagen-specific AI logic was updated directly in its ViewModel.

Further steps, including updating the README.md, remain.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @calren, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

Hello! Gemini here, providing a summary of this pull request. This PR aims to initiate the migration from the older firebase-vertexai SDK to the new firebase-ai (Firebase AI Logic SDK) within the ai-catalog project. The changes involve updating dependency declarations in the Gradle files and refactoring the usage of the AI SDK specifically within the Imagen sample's ViewModel to align with the new SDK's API.

Highlights

  • SDK Migration: The core purpose of this PR is to begin migrating from the firebase-vertexai SDK to the new firebase-ai SDK.
  • Dependency Updates: The Firebase Bill of Materials (BOM) version is updated, and the dependency alias and module name for the Firebase AI SDK are changed in the Gradle version catalog (libs.versions.toml) and the app's build file (build.gradle.kts).
  • Imagen Sample Update: The Imagen sample's ViewModel (ImagenViewModel.kt) is updated to use the new firebase-ai SDK, including changes to imports and the initialization method for the ImagenModel.

Changelog

  • ai-catalog/app/build.gradle.kts
    • Changed the implementation dependency from libs.firebase.vertexai to libs.firebase.ai (line 81).
  • ai-catalog/gradle/libs.versions.toml
    • Bumped the firebaseBom version from 33.12.0 to 33.14.0 (line 4).
    • Renamed the library alias from firebase-vertexai to firebase-ai and updated its module definition (line 34).
  • ai-catalog/samples/imagen/src/main/java/com/android/ai/samples/imagen/ImagenViewModel.kt
    • Updated import statements from com.google.firebase.vertexai.type.* to com.google.firebase.ai.type.* (lines 26-28).
    • Added import for com.google.firebase.ai.ai and com.google.firebase.ai.type.GenerativeBackend (lines 30-31).
    • Refactored the imagenModel initialization from Firebase.vertexAI.imagenModel(...) to Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(...) (line 45).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


SDKs change, code must adapt,
From old VertexAI, now wrapped,
In firebase-ai,
A new way to try,
Dependencies neatly mapped.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively initiates the migration of the Imagen sample within the ai-catalog project from the firebase-vertexai SDK to the new firebase-ai SDK. The changes to the Gradle build files and the ImagenViewModel.kt are clear and directly address the SDK update, particularly the Imagen model initialization and type imports.

I have one point of clarification regarding an import related to a preview API, detailed in the comments. It's also noted from your PR description that further steps, such as updating the README.md, are planned, which is good.

Overall, this is a solid first step in the SDK migration process.

Summary of Findings

  • Clarity on PublicPreviewAPI source with new firebase-ai SDK: The imagenModel is initialized using the new firebase-ai SDK but is annotated with @OptIn(PublicPreviewAPI::class), where PublicPreviewAPI is imported from the older com.google.firebase.vertexai.type namespace. Clarification is requested on whether this is the intended source for the annotation with the new SDK, or if an alternative from firebase-ai should be used.

Merge Readiness

The pull request makes good progress on the SDK migration. There is one medium-severity point of clarification raised regarding the source of the PublicPreviewAPI annotation in ImagenViewModel.kt. It would be beneficial to address this clarification before merging to ensure alignment with the new SDK's best practices.

As an AI, I am not authorized to approve pull requests. Please ensure this PR is reviewed and approved by the appropriate team members. Once the clarification is addressed, these changes appear to be a positive step forward.


@OptIn(PublicPreviewAPI::class)
private val imagenModel = Firebase.vertexAI.imagenModel(
private val imagenModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Thanks for updating the imagenModel initialization to use the new firebase-ai SDK!

This model (and its initialization here on line 45) is annotated with @OptIn(PublicPreviewAPI::class) (as seen on line 44). I notice the PublicPreviewAPI annotation itself is still imported from com.google.firebase.vertexai.type (line 29).

With the migration to firebase-ai, could you clarify if this is the expected source for the PublicPreviewAPI annotation? It would be helpful to confirm whether the new firebase-ai SDK provides its own version of this annotation for preview features, or if this interdependency with the com.google.firebase.vertexai.type namespace is the intended approach for now. Ensuring all related types and annotations align with the new SDK's structure, where possible, would enhance clarity and future maintainability.

@calren calren changed the title [jules] Refactor: Partial Firebase AI SDK update for ai-catalog [jules] Update to use Firebase AI Logic SDK May 22, 2025
@calren
Copy link
Collaborator Author

calren commented May 22, 2025

closing in favor of #33

@calren calren closed this May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant